package common.model
{
	[Bindable]
	[RemoteClass(alias="org.sunleads.common.entity.CmdModel")]
	public class CmdModel
	{
		public function CmdModel(wqStaffInfo:WqStaffInfo){
			this.staffId = wqStaffInfo.id;
			this.cmdStateCode = CMD_PROCESS_CODE;
		}
		
		/**
		 * 等待回复 0
		 */ 
		public static var CMD_PROCESS_CODE:String = "0";
		public static var CMD_PROCESS:String = "等待回复";
		/**
		 * 成功 1
		 */
		public static var CMD_SUCCESS_CODE:String = "1";
		public static var CMD_SUCCESS:String = "成功";
		/**
		 * 失败 2
		 */ 
		public static var CMD_FAIL_CODE:String = "2";
		public static var CMD_FAIL:String = "失败";
		
		/**
		 * 超时 3
		 */ 
		public static var CMD_TIMEOUT_CODE:String = "3";
		public static var CMD_TIMEOUT:String = "超时";
		
		public var staffId:String;//员工编号
		public var cmdTypeCode:String;//指令类型代码
		public var cmdStateCode:String;//指令状态代码
		public var sendTime:String;//发送时间
		public var userName:String;//发送者
		
		
		/**
		 * 获取指令名称
		 */ 
		public function getCmdTypeName(){
			var result:String = "";
			if(cmdTypeCode){
				if("GetPos"==cmdTypeCode){
					result = "获取当前位置";
				}
			}
			return result;
		}
		
		/**
		 * 获取指令状态名称
		 */
		public function getCmdStateName(){
			return CmdModel.getCmdStateNameByStateCode(cmdStateCode);
		}
		
		/**
		 * 根据指令编码获取指令名称
		 */
		public static function getCmdStateNameByStateCode(stateCode:String){
			var result:String = "";
			if(CMD_PROCESS_CODE == stateCode){
				result = CMD_PROCESS;
			}else if(CMD_SUCCESS_CODE == stateCode){
				result = CMD_SUCCESS;
			}else if(CMD_FAIL_CODE == stateCode){
				result = CMD_FAIL;
			}else if(CMD_TIMEOUT_CODE == stateCode){
				result = CMD_TIMEOUT;
			}
			return result;
		}
	}
}